{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd>&nbsp;</dd>
				<dd><a href="wood_help.html"><i class="iconfont">&#xe649;</i>帮助文档</a></dd>
			</dl>
		</div>
		<div class="content">
			<div class="release">
				<dl>
					<dt>
						<i class="iconfont">&#xe649;</i><b>{{.title}}说明</b><br>
						<p>根据需要先选择栏目,<mark>在选择产品</mark></p>
						<p>选择上级商品结构,添加完成后可编辑</p>
					</dt>
				</dl>
			</div>
			<form action="" method="get" autocomplete="on" class="form">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre">名称</td>
						<td colspan="3">
							<input type="text" class="input95" placeholder="请输入名称！" name="name" value="{{.info.name}}">
							<input type="hidden" name="id" value="{{.id}}">
						</td>
						<td class="genre">主题色(如:#ffffff)</td>
						<td colspan="3">
							<input type="text" class="input95" placeholder="#ffffff" value="{{.info.themeColor}}" name="themeColor">
						</td>
					</tr>
					<tr>
						<td class="genre">简介</td>
						<td colspan="7">
							<textarea placeholder="请输入说明，200字内。" class="textarea95" name="introduce">{{.info.introduce}}</textarea>
						</td>
					</tr>
					<tr>
						<td class="genre">图片</td>
						<td colspan="7">
							<div class="thumbnail">
								<dl>
									<dt>
										<img src="{{if .info.pathname}}{{.info.pathname}}{{else}}/static/all/uppic.png{{end}}" class="uppic">
										<input type="file" onchange="uppic(this, 'function')" accept="image/*">
										<input type="hidden" name="img" value="{{.info.img}}">
									</dt>
									<dd>缩略图</dd>
									<dd class="del_img">删除图片</dd>
								</dl>
								<dl>(658 * 332)</dl>
							</div>
						</td>
					</tr>
					<!-- <input type="hidden" name="img" value="{{.info.img}}">
					<tr>
						<td class="genre" colspan="8">
							<input type="text" class="select95 search-all" placeholder="筛选全部">
						</td>
					</tr>
					{{range .column}}
					<tr>
						<td class="genre" colspan="2">
							<label class="checkbox">
								<input type="checkbox" name="cid" value="{{.id}}" {{if $.info.cid}}{{tipcheck .id $.info.cid}}{{end}}>{{.name}}
							</label>
						</td>
						<td colspan="6">
							<input type="text" class="select95 search-cell" placeholder="筛选{{.name}}">
						</td>
					</tr>
					<tr>
						<td colspan="8">
							{{range .product}}
							<label class="checkbox product" style="display: none;">
								<input type="checkbox" name="pid" value="{{.id}}" {{if $.info.pid}}{{tipcheck .id $.info.pid}}{{end}}>{{.title}}
							</label>
							{{end}}
						</td>
					</tr>
					{{end}} -->
			</form>
			<tr class="trbutton">
				<td colspan="2"><button type="button" class="button">保存</button></td>
				<td colspan="6">
					<p>
						<i class="iconfont">&#xe649;</i> 请检查内容确认发布的内容没有涉及传播谣言、政治话题或违反广告法夸大宣传产品等。
					</p>
					<div class="help">帮助
						<div class="help_qr"><img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/all/qr-code.jpg" alt=""></div>
					</div>
				</td>
			</tr>
		</table>
		</div>
	</article>
</section>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
	$('input[name="pid"]').each(function () {
		if($(this).prop('checked'))
			$(this).parent().show()
	})
	function searchProduct(cidEl, reg) {
		cidEl.parents('tr').next('tr').find('.product').each(function () {
			if (reg.test($(this).text())) {
				$(this).show()
			} else {
				$(this).hide()
			}
		})
	}
	$('.search-all').bind('input', function () {
		var val = $(this).val().trim()
		var reg = new RegExp(val)
		$('input[name="cid"]').each(function () {
			if ($(this).prop('checked')) {
				searchProduct($(this), reg)
			}
		})
	})

	$('.search-cell').bind('input', function () {
		var val = $(this).val().trim()
		var reg = new RegExp(val)
		var that = $(this).parents('tr').find('input[name="cid"]')
		searchProduct(that, reg)
	})

	$('input[name="cid"]').change(function (e) {
		var search = $(this).parents('td').next('td').find('.search-cell').val().trim() || $('.search-all').val().trim()
		var reg = new RegExp(search)
		if ($(this).prop('checked')) {
			searchProduct($(this), reg)
		} else {
			$(this).parents('tr').next('tr').find('.product').hide()
		}
	})

	$('.button').click(function () {
		if (!$('input[name="name"]').val().trim()) {
			return window.wxc.xcConfirm("请输入名称！","info")
		}
		if ($('input[name="supe"]').length && !$('input[name="supe"]').val()) {
			return window.wxc.xcConfirm("未选择商品结构!","info")	
		}
		if (!$('input[name="img"]').val()) {
			return window.wxc.xcConfirm("未上传主图!","info")	
		}
		$.ajax({
			url: location.href,
			data: $('form').serialize(),
			type: 'post',
			success: function (res) {
				if (res.status == 1) {
                    window.wxc.xcConfirm("保存成功","success",{onClose: function () {
                    	location = document.referrer
                    }})
				} else {
					window.wxc.xcConfirm("保存失败,请重试!", "error")
				}
			}
		})
	})
</script>
</body>
</html>